/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.i18n;
import javax.swing.*;
import org.openide.cookies.EditorCookie;
import org.netbeans.modules.properties.ResourceBundlePanel;
import org.netbeans.modules.properties.ResourceBundleString;
/**
*
* @author pjiricka
* @version
*/
public class LocalizePanel extends ResourceBundlePanel {
static final long serialVersionUID =-6982482491017390786L;
/** Creates new form LocalizePanel */
public LocalizePanel() {
super(false);
initComponents();
jPanel5.remove (replaceAllButton);
}
public void setLocalizeInfo(LocalizeSupport.LocalizeInfo localizeInfo) {
stringField.setText(localizeInfo.getHardString());
foundinField.setText(localizeInfo.getHardLine());
componentField.setText(localizeInfo.getComponentName());
propertyField.setText(localizeInfo.getPropertyName());
}
private void buttonsEnableDisable() {
boolean isBundle = (value.getResourceBundle() != null);
boolean isInvalid = (value instanceof LocalizeSupport.InvalidResourceBundleString);
replaceButton.setEnabled(isBundle && !isInvalid);
replaceAllButton.setEnabled(isBundle);
}
public void setValue(ResourceBundleString str) {
super.setValue(str);
buttonsEnableDisable();
}
public void updateStatus(boolean bundleChanged) {
super.updateStatus(bundleChanged);
if (bundleChanged)
editButton2.setEnabled(value.getResourceBundle() != null);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
private void initComponents () {//GEN-BEGIN:initComponents
setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints1;
setBorder (new javax.swing.border.EmptyBorder(new java.awt.Insets(8, 8, 8, 8)));
jPanel1 = new javax.swing.JPanel ();
jPanel1.setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints2;
jPanel1.setBorder (new javax.swing.border.TitledBorder(
new javax.swing.border.EtchedBorder(), "Hardcoded string"));
jPanel1.setEnabled (false);
jLabel1 = new javax.swing.JLabel ();
jLabel1.setText ("String:");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (8, 8, 8, 8);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
jPanel1.add (jLabel1, gridBagConstraints2);
stringField = new javax.swing.JTextField ();
stringField.setBackground (java.awt.Color.lightGray);
stringField.setEditable (false);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (8, 0, 8, 8);
gridBagConstraints2.weightx = 1.0;
jPanel1.add (stringField, gridBagConstraints2);
jLabel2 = new javax.swing.JLabel ();
jLabel2.setText ("Found in:");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (0, 8, 8, 8);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
jPanel1.add (jLabel2, gridBagConstraints2);
foundinField = new javax.swing.JTextField ();
foundinField.setBackground (java.awt.Color.lightGray);
foundinField.setEditable (false);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (0, 0, 8, 8);
gridBagConstraints2.weightx = 1.0;
jPanel1.add (foundinField, gridBagConstraints2);
jLabel5 = new javax.swing.JLabel ();
jLabel5.setText ("Component:");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (0, 8, 8, 8);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
jPanel1.add (jLabel5, gridBagConstraints2);
componentField = new javax.swing.JTextField ();
componentField.setBackground (java.awt.Color.lightGray);
componentField.setEditable (false);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (0, 0, 8, 8);
jPanel1.add (componentField, gridBagConstraints2);
jLabel6 = new javax.swing.JLabel ();
jLabel6.setText ("Property:");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (0, 8, 8, 8);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
jPanel1.add (jLabel6, gridBagConstraints2);
propertyField = new javax.swing.JTextField ();
propertyField.setBackground (java.awt.Color.lightGray);
propertyField.setEditable (false);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (0, 0, 8, 8);
jPanel1.add (propertyField, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.weightx = 1.0;
add (jPanel1, gridBagConstraints1);
jPanel2 = new javax.swing.JPanel ();
jPanel2.setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints3;
jPanel2.setBorder (new javax.swing.border.TitledBorder(
new javax.swing.border.EtchedBorder(), "Resource Bundle"));
bundleText2 = new javax.swing.JTextField ();
bundleText2.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
bundleText2ActionPerformed (evt);
}
}
);
bundleText2.addFocusListener (new java.awt.event.FocusAdapter () {
public void focusLost (java.awt.event.FocusEvent evt) {
bundleText2FocusLost (evt);
}
}
);
gridBagConstraints3 = new java.awt.GridBagConstraints ();
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets (0, 8, 0, 8);
gridBagConstraints3.weightx = 1.0;
jPanel2.add (bundleText2, gridBagConstraints3);
browseButton2 = new javax.swing.JButton ();
browseButton2.setText ("Browse...");
browseButton2.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
browseButton2ActionPerformed (evt);
}
}
);
gridBagConstraints3 = new java.awt.GridBagConstraints ();
gridBagConstraints3.gridwidth = 0;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets (8, 0, 8, 8);
jPanel2.add (browseButton2, gridBagConstraints3);
newButton2 = new javax.swing.JButton ();
newButton2.setText ("New...");
newButton2.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
newButton2ActionPerformed (evt);
}
}
);
gridBagConstraints3 = new java.awt.GridBagConstraints ();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.gridwidth = 0;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets (0, 0, 8, 8);
jPanel2.add (newButton2, gridBagConstraints3);
editButton2 = new javax.swing.JButton ();
editButton2.setText ("Edit...");
editButton2.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
editButton2ActionPerformed (evt);
}
}
);
gridBagConstraints3 = new java.awt.GridBagConstraints ();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.gridwidth = 0;
gridBagConstraints3.gridheight = 0;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets (0, 0, 8, 8);
jPanel2.add (editButton2, gridBagConstraints3);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints1.weightx = 1.0;
add (jPanel2, gridBagConstraints1);
jPanel3 = new javax.swing.JPanel ();
jPanel3.setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints4;
jPanel3.setBorder (new javax.swing.border.TitledBorder(
new javax.swing.border.EtchedBorder(), "String"));
jLabel3 = new javax.swing.JLabel ();
jLabel3.setText ("Key:");
gridBagConstraints4 = new java.awt.GridBagConstraints ();
gridBagConstraints4.insets = new java.awt.Insets (8, 8, 0, 8);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST;
jPanel3.add (jLabel3, gridBagConstraints4);
keyComboBox2 = new javax.swing.JComboBox ();
keyComboBox2.setEditable (true);
keyComboBox2.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
keyComboBox2ActionPerformed (evt);
}
}
);
gridBagConstraints4 = new java.awt.GridBagConstraints ();
gridBagConstraints4.gridwidth = 0;
gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints4.insets = new java.awt.Insets (8, 0, 0, 8);
gridBagConstraints4.weightx = 1.0;
jPanel3.add (keyComboBox2, gridBagConstraints4);
jLabel4 = new javax.swing.JLabel ();
jLabel4.setText ("Value:");
gridBagConstraints4 = new java.awt.GridBagConstraints ();
gridBagConstraints4.insets = new java.awt.Insets (8, 8, 0, 8);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;
jPanel3.add (jLabel4, gridBagConstraints4);
jScrollPane1 = new javax.swing.JScrollPane ();
valueTextArea2 = new javax.swing.JTextArea ();
valueTextArea2.setRows (4);
valueTextArea2.addFocusListener (new java.awt.event.FocusAdapter () {
public void focusLost (java.awt.event.FocusEvent evt) {
valueTextArea2FocusLost (evt);
}
}
);
jScrollPane1.setViewportView (valueTextArea2);
gridBagConstraints4 = new java.awt.GridBagConstraints ();
gridBagConstraints4.gridwidth = 0;
gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints4.insets = new java.awt.Insets (8, 0, 8, 8);
gridBagConstraints4.weightx = 1.0;
gridBagConstraints4.weighty = 1.0;
jPanel3.add (jScrollPane1, gridBagConstraints4);
paramsButton2 = new javax.swing.JButton ();
paramsButton2.setText (org.openide.util.NbBundle.getBundle(LocalizePanel.class).getString("ResourceBundlePanel.paramsButton.text"));
paramsButton2.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
paramsButton2ActionPerformed (evt);
}
}
);
gridBagConstraints4 = new java.awt.GridBagConstraints ();
gridBagConstraints4.gridx = 1;
gridBagConstraints4.gridwidth = 0;
gridBagConstraints4.gridheight = 0;
gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST;
jPanel3.add (paramsButton2, gridBagConstraints4);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
add (jPanel3, gridBagConstraints1);
jPanel5 = new javax.swing.JPanel ();
jPanel5.setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints5;
replaceButton = new javax.swing.JButton ();
replaceButton.setPreferredSize (new java.awt.Dimension(89, 27));
replaceButton.setMaximumSize (new java.awt.Dimension(89, 27));
replaceButton.setMinimumSize (new java.awt.Dimension(89, 27));
replaceButton.setText ("Replace");
gridBagConstraints5 = new java.awt.GridBagConstraints ();
gridBagConstraints5.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints5.insets = new java.awt.Insets (8, 0, 0, 8);
gridBagConstraints5.weightx = 1.0;
jPanel5.add (replaceButton, gridBagConstraints5);
replaceAllButton = new javax.swing.JButton ();
replaceAllButton.setText ("Replace All");
gridBagConstraints5 = new java.awt.GridBagConstraints ();
gridBagConstraints5.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints5.insets = new java.awt.Insets (8, 0, 0, 8);
gridBagConstraints5.weightx = 1.0;
jPanel5.add (replaceAllButton, gridBagConstraints5);
skipButton = new javax.swing.JButton ();
skipButton.setPreferredSize (new java.awt.Dimension(89, 27));
skipButton.setMaximumSize (new java.awt.Dimension(89, 27));
skipButton.setMinimumSize (new java.awt.Dimension(89, 27));
skipButton.setText ("Skip");
gridBagConstraints5 = new java.awt.GridBagConstraints ();
gridBagConstraints5.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints5.insets = new java.awt.Insets (8, 0, 0, 8);
gridBagConstraints5.weightx = 1.0;
jPanel5.add (skipButton, gridBagConstraints5);
cancelButton = new javax.swing.JButton ();
cancelButton.setPreferredSize (new java.awt.Dimension(89, 27));
cancelButton.setMaximumSize (new java.awt.Dimension(89, 27));
cancelButton.setMinimumSize (new java.awt.Dimension(89, 27));
cancelButton.setText ("Cancel");
gridBagConstraints5 = new java.awt.GridBagConstraints ();
gridBagConstraints5.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints5.insets = new java.awt.Insets (8, 0, 0, 0);
gridBagConstraints5.weightx = 1.0;
jPanel5.add (cancelButton, gridBagConstraints5);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.weightx = 1.0;
add (jPanel5, gridBagConstraints1);
}//GEN-END:initComponents
private void paramsButton2ActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_paramsButton2ActionPerformed
paramsButtonActionPerformed_(evt);
}//GEN-LAST:event_paramsButton2ActionPerformed
private void newButton2ActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButton2ActionPerformed
newButtonActionPerformed_(evt);
buttonsEnableDisable();
}//GEN-LAST:event_newButton2ActionPerformed
private void bundleText2ActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bundleText2ActionPerformed
bundleTextActionPerformed_(evt);
buttonsEnableDisable();
}//GEN-LAST:event_bundleText2ActionPerformed
private void keyComboBox2ActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyComboBox2ActionPerformed
keyComboBoxActionPerformed_(evt);
}//GEN-LAST:event_keyComboBox2ActionPerformed
private void editButton2ActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButton2ActionPerformed
//System.out.println("editing " + value.getResourceBundle().getPrimaryFile().getPackageNameExt('/','.'));
EditorCookie editor = (EditorCookie)value.getResourceBundle().getCookie(EditorCookie.class);
//System.out.println("editorcookie " + editor);
if (editor != null)
editor.open();
}//GEN-LAST:event_editButton2ActionPerformed
private void bundleText2FocusLost (java.awt.event.FocusEvent evt) {//GEN-FIRST:event_bundleText2FocusLost
bundleTextFocusLost_(evt);
buttonsEnableDisable();
}//GEN-LAST:event_bundleText2FocusLost
private void valueTextArea2FocusLost (java.awt.event.FocusEvent evt) {//GEN-FIRST:event_valueTextArea2FocusLost
valueTextAreaFocusLost_(evt);
}//GEN-LAST:event_valueTextArea2FocusLost
private void browseButton2ActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButton2ActionPerformed
browseButtonActionPerformed_(evt);
buttonsEnableDisable();
}//GEN-LAST:event_browseButton2ActionPerformed
public javax.swing.JButton[] getButtons() {
return new javax.swing.JButton[] { replaceButton, replaceAllButton, skipButton, cancelButton };
}
// component accessors
protected JTextField bundleText_() {
return bundleText2;
}
protected JComboBox keyComboBox_() {
return keyComboBox2;
}
protected JTextArea valueTextArea_() {
return valueTextArea2;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel jLabel1;
private javax.swing.JTextField stringField;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField foundinField;
private javax.swing.JLabel jLabel5;
private javax.swing.JTextField componentField;
private javax.swing.JLabel jLabel6;
private javax.swing.JTextField propertyField;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField bundleText2;
private javax.swing.JButton browseButton2;
private javax.swing.JButton newButton2;
private javax.swing.JButton editButton2;
private javax.swing.JPanel jPanel3;
private javax.swing.JLabel jLabel3;
private javax.swing.JComboBox keyComboBox2;
private javax.swing.JLabel jLabel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea valueTextArea2;
private javax.swing.JButton paramsButton2;
private javax.swing.JPanel jPanel5;
private javax.swing.JButton replaceButton;
private javax.swing.JButton replaceAllButton;
private javax.swing.JButton skipButton;
private javax.swing.JButton cancelButton;
// End of variables declaration//GEN-END:variables
}